sigchld_owner = 0;
}
+static void sigchld_installhandler_core(libxl__gc *gc)
+{
+ struct sigaction ours;
+ int r;
+
+ assert(!sigchld_owner);
+ sigchld_owner = CTX;
+
+ memset(&ours,0,sizeof(ours));
+ ours.sa_handler = sigchld_handler;
+ sigemptyset(&ours.sa_mask);
+ ours.sa_flags = SA_NOCLDSTOP | SA_RESTART;
+ r = sigaction(SIGCHLD, &ours, &sigchld_saved_action);
+ assert(!r);
+
+ assert(((void)"application must negotiate with libxl about SIGCHLD",
+ !(sigchld_saved_action.sa_flags & SA_SIGINFO) &&
+ (sigchld_saved_action.sa_handler == SIG_DFL ||
+ sigchld_saved_action.sa_handler == SIG_IGN)));
+}
+
void libxl__sigchld_notneeded(libxl__gc *gc) /* non-reentrant, idempotent */
{
int rc;
atfork_lock();
if (sigchld_owner != CTX) {
- struct sigaction ours;
-
- assert(!sigchld_owner);
- sigchld_owner = CTX;
-
- memset(&ours,0,sizeof(ours));
- ours.sa_handler = sigchld_handler;
- sigemptyset(&ours.sa_mask);
- ours.sa_flags = SA_NOCLDSTOP | SA_RESTART;
- r = sigaction(SIGCHLD, &ours, &sigchld_saved_action);
- assert(!r);
-
- assert(((void)"application must negotiate with libxl about SIGCHLD",
- !(sigchld_saved_action.sa_flags & SA_SIGINFO) &&
- (sigchld_saved_action.sa_handler == SIG_DFL ||
- sigchld_saved_action.sa_handler == SIG_IGN)));
+ sigchld_installhandler_core(gc);
}
atfork_unlock();